package com.parking.mgr.useraccount.config;

import com.parking.mgr.useraccount.interceptor.LoginAuthInterceptor;
import com.parking.mgr.useraccount.interceptor.PermissionUrlInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @ClassName InterceptorConfig
 * @Description TODO
 * @Auther: zhijianpu
 * @Date: 2023/6/12
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    @Bean
    public LoginAuthInterceptor loginAuthInterceptor() {
        return new LoginAuthInterceptor();
    }

    @Bean
    public PermissionUrlInterceptor permissionUrlInterceptor() {
        return new PermissionUrlInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录拦截
        registry.addInterceptor(loginAuthInterceptor());
        // URL权限拦截
        registry.addInterceptor(permissionUrlInterceptor());
    }
}
